#!/bin/bash

# Retrieves the estimated remaining pages printable with available toner from each printer

# Create the array for printer names

printer_names=( baskerville cleveland lib_iif lib_1st_flr lib_2nd_flr norris2 read2 \
		scilab scilib jrc_email younker2 helpdesk duerer gencomp2 inslab )

for ((i=0; i < ${#printer_names[@]}; i++))
do

# Download supplies pages

wget -T 2 -t 2 "${printer_names[$i]}".grinnell.edu/hp/device/this.LCDispatcher?nav=hp.Supplies -O $HOME/printers/status_pages/"${printer_names[$i]}"_supplies

# ... and search to grab the number

grep -A 3 "Estimated Pages Remaining:" $HOME/printers/status_pages/"${printer_names[$i]}"_supplies | egrep "[0-9]{0,5}" -o > $HOME/printers/estimated_paper/"${printer_names[$i]}"_paper

done

exit 0
